< previous page page_57 next page >

Page 57
e10a6a0a59f035e870d90cca05b85fce.gif
typedef struct tagBITMAP {
    int      bmType;
    int      bmWidth;
    int      bmHeight;
    int      bmWidthBytes;
    BYTE     bmPlanes;
    BYTE     bmBitsPixel;
    void FAR*       bmBits;
} BITMAP;
To use the GetObject function, you must pass it a BITMAP data structure. You can define this structure in Visual Basic using a Type statement like this:
e10a6a0a59f035e870d90cca05b85fce.gif
Type BITMAP 
    bmType As Integer 
    bmWidth As Integer 
    bmHeight As Integer 
    bmWidthBytes As Integer 
    bmPlanes As String * 1 
    bmBitsPixel As String * 1 
    bmBits As Long 
End Type
Visual Basic comes with the file Win32api.txt that contains declarations for types, constants, and functions useful when you are working with the API. For example, this file contains the definition of the BITMAP data type.
By default, Win32api.txt is installed in the Program Files\Microsoft Visual Studio\ Common\Tools\Winapi directory. If you cannot find it there, search your Visual Basic CD-ROM for files that match the pattern *api*.
If you want, you can include this file directly into your Visual Basic project, and all of the API types, constants, and functions will be defined for you. Unfortunately, this file is large (653KB on my computer), so it makes your program quite large. Instead of including the entire file, you can cut and paste the declarations you need into your project.
You can also use the API Viewer application that comes with Visual Basic to copy the definitions you need. The API Viewer, shown in Figure 2.1, is the program Apiload.exe and should be in the same directory as the file Win32api.txt.
Select the File menu's Load Text File command and load Win32api.txt. Pick Types from the API Type combo box to see a list of the data type declarations. Select the data types you need and click the Add button to build a list of items for copying into your program.
When the list is complete, click the Copy button. The API Viewer copies the selected declarations into the clipboard. You can now open a module in Visual Basic and press CTRL-V to paste the declarations from the clipboard into your project.

 
< previous page page_57 next page >